﻿
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Uinside.CreditSystem.DomainModels.Models;

namespace Uinside.CreditSystem.Services
{
    public class PaymentService : BaseService
    {
        public PaymentService(CreditContext dbContext)
            : base(dbContext)
        {
        }

        public IEnumerable<Payment> GetAll()
        {
            return this._creditContext.Payments;
        }

        public void Delete(IEnumerable<Payment> payments)
        {
            var list = payments.ToList();
            foreach (var pay in list)
            {
                if (this._creditContext.Entry(pay).State != EntityState.Detached)
                    this._creditContext.Payments.Remove(pay);

            }
        }

        public void InsertNewPayment()
        {
            //var payment = new Payment();
            //payment.TypeId = PaymentTypeService.GetAll().First(i => i.Value == 3).Id;
            //payment.BorrowerId = CurrentItem.BorrowerId;
            //payment.LenderId = CurrentItem.LenderId;
            //payment.StatusId = PaymentStatusService.GetAll().First(i => i.Value == 1).Id;
            //payment.RemindDate = CurrentItem.ReturnDate.AddDays(-CurrentItem.PriorToRemind);
            //payment.ExpectDate = CurrentItem.ReturnDate;
            //payment.PaymentDate = null;
            //payment.Sum = CurrentItem.SumOfLoan * (decimal)CurrentItem.InterestRate;
            //_creditContext.Payments.Add(payment);
        }
    }
}
